<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/modify_information.css"/>
	</head>
	<body>
		<div class="content">
			<h2>基本信息</h2>
<!--更换头像-->
<div class="upfile">
	<div class="now_img">
		<img id="personimg" name="m_personimg" width="100" height="100">
	</div>
	<div class="imgjs">
		<form class="am-form" id="uploadForm">
			<!--<div class="am-form-group">-->
			<!--<br/>-->
			<input style="margin-left: 150px;" type="file" id="user-pic" name="logo"/>
			<!--<br/>-->
			<!--<br/>-->
			<input id="btn" type="button" value="保存"/>
			<!--<button type="button" onclick="doUpload()">保存</button>-->
			<!--</div>-->
		</form>
	</div>
</div>
<!--修改资料-->
			<form id="myform" class="xx">
				<p>
					<span>姓名</span> <input name="m_name" />
				</p>				
				<p>
					<span>邮箱</span> <input name="m_email" />					
				</p>
				<p>					
					<span>手机</span> <input name="m_tel" />				
				</p>
				<p>					
					<span>电话</span> <input name="m_phone" />					
				</p>
				<p>					
					<span>公司</span> <input name="m_company" />					
				</p>
				<p>
					<span>部门</span> <input name="m_department" />					
				</p>
				<p>
					<span>备注</span> <input name="m_Remarks" />					
				</p>
				<p class="last">
					<span>个人简介</span> <textarea name="profile"></textarea>
				</p>
				<p style="clear: both;">
					<button type="submit" id="bt1">确定</button>
					<button type="reset">重置</button>
				</p>
				
			</form>
		</div>
	</body>
</html>

<script src="js/jquery.js"></script>
<script>
$(function () {
	$.ajax({
           type: "POST",
           url: "http://localhost:5656/person",
	}).then(function (res) {
           $('#personimg').attr("src", 'img/' + res[0].personimg);
           $('input[name="m_name"]').val(res[0].name);
           $('input[name="m_email"]').val(res[0].email);
           $('input[name="m_tel"]').val(res[0].tel);
           $('input[name="m_phone"]').val(res[0].phone);
           $('input[name="m_company"]').val(res[0].company);
           $('input[name="m_department"]').val(res[0].department);
           $('input[name="m_Remarks"]').val(res[0].remarks);
           $('textarea[name="profile"]').val(res[0].profile);
       })


       $("#btn").on("click", function(){
           var arr=($('#user-pic').val()).split('\\');
		$("img").attr("src","img/"+arr[2]);
           $.ajax({
               type : "POST",
               url : "http://localhost:5656/personimg",
               data : {
                   m_personimg : arr[2],
               },
           }).then(function(res){
               console.log(res);
           })
           return false;
       })



       $("#bt1").on("click",function () {
           console.log($('textarea[name="profile"]').val());
           $.ajax({
               type: "POST",
               url: "http://localhost:5656/updataperson",
			data:{
                   m_name:$('input[name="m_name"]').val(),
                   m_email:$('input[name="m_email"]').val(),
                   m_tel:$('input[name="m_tel"]').val(),
                   m_phone:$('input[name="m_phone"]').val(),
                   m_company:$('input[name="m_company"]').val(),
                   m_department:$('input[name="m_department"]').val(),
                   m_Remarks:$('input[name="m_Remarks"]').val(),
                   profile:$('textarea[name="profile"]').val(),
                   m_personimg : arr[2],
			}
		}).then(function (res) {
               console.log(res);
           })
		return false;
       })
   })

</script>
